package com.tbit.uqbike.service.base.impl;

import com.tbit.uqbike.object.pojo.NameCount;
import com.tbit.uqbike.object.pojo.statistics.OrderCumSta;
import com.tbit.uqbike.service.base.OrderCumStaService;
import com.tbit.uqbike.service.base.RedisService;
import com.tbit.uqbike.webmanager.dao.stat.OrderCumStaDao;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author jing
 * @date 2020/11/1819:12
 * @Description:
 */
@Service("orderCumStaService")
public class OrderCumStaServiceImpl implements OrderCumStaService {
    @Autowired
    private OrderCumStaDao orderCumStaDao;
    @Autowired
    private RedisService redisService;

    @Override
    public void insert(OrderCumSta orderCumSta) {
        orderCumSta.setUpdateTime(new Date(System.currentTimeMillis()));
        orderCumStaDao.insert(orderCumSta);
    }

    @Override
    public List<OrderCumSta> getByAccountId(Map<String, Object> params) {
        return orderCumStaDao.queryById(params);
    }

    @Override
    public List<OrderCumSta> getByRegionId(Map<String, Object> params) {
        return orderCumStaDao.queryByRegionId(params);
    }

    @Override
    public void updateByMap(Map<String, Object> params) {
        orderCumStaDao.updateByTime(params);
    }

    @Override
    public void updateByMapByRegionId(Map<String, Object> params) {
        orderCumStaDao.updateByTimeAndRegionId(params);
    }

    @Override
    public List<NameCount> statTotalMoney(@Param("idList") List<Integer> idList, @Param("flag") Integer flag) {
        return orderCumStaDao.selectStatTotalMoney(idList, flag);
    }

    @Override
    public void insertBatch(List<OrderCumSta> entities) {
        orderCumStaDao.insertBatch(entities);
    }
}
